package com.example.schooljava.controller;


import com.example.schooljava.annotation.RequestLimit;
import com.example.schooljava.pojo.entity.Exam;
import com.example.schooljava.service.impl.ExamServiceImpl;
import com.example.schooljava.util.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author LDH
 * @since 2022/08/11
 */
@RestController
@RequestMapping("/school/exam")
@RequestLimit(maxCount = 5,second = 2)
@Api(tags = "考试成绩模块")
public class ExamController {
    @Autowired
    private ExamServiceImpl examService;


    @ApiOperation(value = "录入考试成绩",notes = "<span style='color:red;'>详细描述：</span>&nbsp;只能单条录入")
    @PostMapping(value = "/single", name = "班级助理")
    public Result inPutScore(@RequestBody Exam exam){
        return examService.inPutScore(exam);
    }

    @ApiOperation(value = "批量录入考试成绩",notes = "<span style='color:red;'>详细描述：</span>&nbsp;可以同时录入多个exam实体")
    @PostMapping(value = "/list", name = "班级助理")
    public Result inPutList(@RequestBody Map<String, List<Exam>> exams){
        return examService.inPutList(exams);
    }
}
